<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <div>
        <p></p>
        <p></p>
        <p></p>
        <p></p>
        <p></p>
        <p>
            <button>取消</button><button>支付</button>
        </p>
    </div>
    <script>
        // // 声明
        // const btn = document.getElementsByTagName('button')[1]
        // // 绑定事件
        // btn.onclick = () => {
        //     let res = window.confirm('确认支付吗？')
        //     // res为true时跳转到另一个页面
        //     if (res) {
        //         location.href = 'http://127.0.0.1:5501/js%E7%BB%8F%E5%85%B8%E6%A1%88%E4%BE%8B/first-b.htm'
        //     }
        // }


        // 点击按钮,弹出确认框点击确认,页面跳转
        const btn = document.getElementsByTagName('button')[1]
        btn.onclick = () => {
            let res = window.confirm('确认支付吗？')
            if (res) {
                location.href = 'http://127.0.0.1:5501/js%E7%BB%8F%E5%85%B8%E6%A1%88%E4%BE%8B/first-b.htm'
            }
        }

    </script>
</body>

</html>